package br.unifor.cct.mia.pso;

import br.unifor.cct.mia.dataenhancement.Database;
import br.unifor.cct.mia.dataenhancement.Structure;
import br.unifor.cct.mia.evolutionary.SpeciesConstants;
import br.unifor.cct.mia.util.LoadFile;


public class PSOFS extends PSO {

	private double minVal = 0;
	private double maxVal = 1;
	
	private static String[] configuracoes = {
		"br.unifor.cct.mia.initialize.PSOBasicRandonInitialize",
		"br.unifor.cct.mia.velocity.PSOSimpleVelocity",
		"br.unifor.cct.mia.evaluate.pso.PSOWekaFSEvaluate"
	};	
	private Integer specieType = new Integer(SpeciesConstants.FEATURE_SELECTION);
	
	public static void main(String arg[]) {
		final String DATASET_STRUCTURE = "E:\\Pedro\\Convertidas\\soybean_struc.txt";
		final String DATASET_DATA = "E:\\Pedro\\Convertidas\\soybean_data.txt";
		
		Structure st = LoadFile.loadStructure(DATASET_STRUCTURE);
    	Database db = LoadFile.loadDatabase(DATASET_DATA);
		
		PSO pso = new PSOFS(db,st,null);
		pso.setPopSize(20);
		pso.setExecSize(10);
		new Thread(pso).start();
	}
	
	public PSOFS(Database dbOriginal, Structure structure, String[] options) {
    	super(structure.size()-1, configuracoes, options);
		System.out.println("[FS]Numero de atributos -> "+structure.size());
		this.dbOriginal = dbOriginal;
    	this.structure = structure;
	}
	
	@Override
	public Object[] getObjectsEvaluate() {
		Object[] o =  new Object[3];
		o[0] = this;
		o[1] = structure;
		o[2] = dbOriginal;
		return o;
	}

	@Override
	public Object[] getObjectsInitialize() {
		Object[] o =  new Object[4];
		o[0] = this.getConfigurations();
		o[1] = this.getPopulacao();
		o[2] = new Double(this.minVal);
		o[3] = new Double(this.maxVal);
		return o;
	}

	@Override
	public Object[] getObjectsVelocity() {
		Object[] o =  new Object[1];
		o[0] = this;
		return o;
	}

	@Override
	public void graphic() {
		graphic.addPointLinha(0, geracao, getBestIndividual().getFitness());    	
	}

	public double getMinVal() {
		return minVal;
	}
	public void setMinVal(double minVal) {
		this.minVal = minVal;
	}
	public double getMaxVal() {
		return maxVal;
	}
	public void setMaxVal(double maxVal) {
		this.maxVal = maxVal;
	}
	public Integer getSpecieType() {
		return specieType;
	}
	public void setSpecieType(Integer specieType) {
		this.specieType = specieType;
	}
}
